import os
from openai import OpenAI

client = OpenAI(
    # 若没有配置环境变量，请用阿里云百炼API Key将下行替换为：api_key="sk-xxx",
    api_key="sk-297c553e64b844b4a6e7fa8e7bc71f12",# os.getenv("DASHSCOPE_API_KEY"),
    base_url="https://dashscope.aliyuncs.com/compatible-mode/v1"
)

completion = client.chat.completions.create(
    model="Moonshot-Kimi-K2-Instruct",
    messages=[
        {'role': 'user', 'content': '你是谁'}
    ]
)

print(completion.choices[0].message.content)